package com.ruoyi.system.api.domain.store;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 报损单对象 finer_stock_loss
 *
 * @author wl
 * @date 2024-11-04
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class StockLoss implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    private Integer id;

    /**
     * 单据编号
     */
    @Excel(name = "单据编号")
    private String orderCode;

    /**
     * 单据日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "单据日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date orderDate;

    /**
     * 报损类型  0：采购入库报损1：销售退货报损2：仓库盘点报损
     */
    private Integer lossType;

    //报损类型名称
    @Excel(name = "报损类型")
    private String lossTypeName;

    /**
     * 源单号
     */
    @Excel(name = "源单号")
    private String srcOrderCode;

    /**
     * 报损商品总数
     */
    @Excel(name = "报损总数")
    private Integer lossTotal;

    /**
     * 报损商品总价
     */
    @Excel(name = "报损总价")
    private BigDecimal lossPrice;

    //创建人
    @Excel(name = "创建人")
    private String createBy;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date createDate;

    /**
     * 修改人
     */
    @Excel(name = "修改人")
    private String modifyBy;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date modifyDate;

    /**
     * 是否删除：0未删除1已删除
     */
    private Integer isDel;

    //备注
    @Excel(name = "备注")
    private String remark;

    //明细
    private List<StockLossDetail> stockLossDetailList;

    /**
     * 请求参数
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String, Object> params;

    /**
     * 搜索值
     */
    @JsonIgnore
    private String searchValue;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }

    public void setParams(Map<String, Object> params) {
        this.params = params;
    }

    public void setLossType(Integer lossType) {
        this.lossType = lossType;
        if (lossType == null) {
            return;
        }
        if (lossType == 0) {
            this.lossTypeName = "采购入库报损单";
        }
        if (lossType == 1) {
            this.lossTypeName = "销售退货报损单";
        }
        if (lossType == 2) {
            this.lossTypeName = "仓库盘点报损单";
        }
    }
}
